package com.weishi.project.sport.home.controller;

import com.weishi.framework.web.controller.BaseController;
import com.weishi.framework.web.domain.AjaxResult;
import com.weishi.project.api.vo.LoginVo;
import com.weishi.project.sport.home.service.SportLoginService;
import com.weishi.project.training.domain.Sportsman;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@Api(value = "运动员端--登录", description = "运动员端--登录")
@RestController
@CrossOrigin("*")//解决移动端跨域
@RequestMapping("/sport/")
public class SportLoginController extends BaseController {

    /**
     * 运动员登录接口
     */
    @Autowired
    private SportLoginService sportLoginService;


    @ApiOperation("运动员端 登录")
    @RequestMapping(value = "login", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult sportLogin(LoginVo login)
    {
        return sportLoginService.sportLogin(login);
    }

    @RequestMapping(value = "info", method = RequestMethod.GET)
    @ResponseBody
    public AjaxResult sportLogin()
    {
        return AjaxResult.success(currentLoginSportsman());
    }


    @ApiOperation("运动员端 退出登录")
    @RequestMapping(value = "sportLogout", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult sportLogout(HttpServletRequest request)
    {
        return sportLoginService.sportLogout(request);
    }


    @ApiOperation("运动员端 注册")
    @RequestMapping(value = "register", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult register(Sportsman sportsman)
    {
        return sportLoginService.register(sportsman);
    }









}
